<?php
include(dirname(__FILE__).'/top-bottom-share-data.php');
$GLOBALS['error_message'] = '';
$GLOBALS['mail_sent_out'] = FALSE;
$act = isset($_REQUEST['act'])?$_REQUEST['act']:'';
$dt = new DataTable(constant('DB_TABLE_MEMBER'));
if ( $act == 'send' ) {
	$email = $_REQUEST['email'];
	$condition = sprintf("`email`='%s'",Util::sql_safe($email));
	$row = $dt->get_row($condition);
	if ( $row ) {
		send_out_reg_verify_email($row['email'], $row['password']);
		$GLOBALS['mail_sent_out'] = TRUE;
		$GLOBALS['mail_sent_out_email'] = $row['email'];
	}else{
		$GLOBALS['error_message'] = '郵箱地址不存在';
	}
}
function send_out_reg_verify_email($email,$password)
{
	$body = file_get_contents(constant ( 'APP_DIR' ) . '/config/forgot_password_template.html');
	$link = constant('SITE_URL_PATH').'/menberb-email-forgot-password.php';
	$code = 'email='.$email.'&password='.$password;
	$code = base64_encode($code);
	$link .= '?code='.$code;
	$body = preg_replace('/\[\[\$LINK\]\]/',$link,$body);
	
	
	$GLOBALS['APP_INSTANCE']->send_out_email($email,'班尼頓密碼找回',$body);
	
}
?>